<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class HotcityController extends AdminbaseController {

	//热门城市列表
	function hot_lst(){
		$dat = M("hot_city")->where("is_del=0")->select();
		$this->assign("data",$dat);
		$this->display();
	}
	//热门城市添加
	function hot_add(){
		if(IS_POST){
			$dat['name'] = trim(I("name"));
			$dat['ctime'] = time();
			$dat['is_del'] = 0;
			M("hot_city")->add($dat);
			$this->success("添加成功",U("Hotcity/hot_lst"));
		}else{
			$this->display();
		}
	}

	//热门城市删除
	function hot_del(){
		$id = I("id");
		$cha = M("hot_city")->where("id=$id")->find();
		if($cha['is_del']==0){
			$dd['is_del'] = 1;
		}
		$gai = M("hot_city")->where("id=$id")->save($dd);

		if($gai){
			$this->success("删除成功", U("Hotcity/hot_lst"));
		}else{
			$this->error("删除失败");
		}
	}

	//热门城市编辑
	function hot_edit(){
		if(IS_POST){
			$id = I("id");
			$data["name"] = I("name");
			$data["ctime"] = time();
			M("hot_city")->where("id=$id")->save($data);
			$this->success("修改成功",U("Hotcity/hot_lst"));
		}else{
			$id = I("id");
			$data = M("hot_city")->where("id=$id")->find();
			$this->assign("id",$id);
			$this->assign("data",$data);
			$this->display();
		}
	}



}